from starlette.middleware.cors import CORSMiddleware

from setting import setting


def registerMiddleware(app):
    if setting.api_cors_origins:
        app.add_middleware(
            CORSMiddleware,
            allow_origins=[str(origin) for origin in setting.api_cors_origins],
            allow_credentials=True,
            allow_methods=["*"],
            allow_headers=["*"],
        )